package com.example.maybeaccount.Mode;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/** 数据库辅助，主要用于创建表 */
public class OpenHelper extends SQLiteOpenHelper {

    //建表语句  用户表
    public static final String CREATE_USER = "create table User ("
            + "id integer primary key autoincrement, "
            + "default_meth integer, "
            + "username text, "
            + "userpwd text, "
            + "gridpwd text)";

    //建表语句  账单表
    public static final String CREATE_ITEM = "create table ITEM("
            +"id integer primary key autoincrement, "
            +"amount real, "
            +"class1 text, "
            +"class2 text, "
            +"account text, "
            +"mode integer, "
            +"payBackTime text, "
            //+"year int, "
            //+"month int, "
            //+"day int, "
            //+"hour int, "
            //+"minute int, "
            +"time text, "
            +"member text, "
            +"shop text, "
            +"project text, "
            +"remark text)";

    //建表语句  账户表
    public static final String CREATE_ACCOUNT = "create table ACCOUNT("
            +"id integer primary key autoincrement, "
            +"name text, "
            +"class text, "
            +"amount text, "
            +"income real, "
            +"expend real, "
            +"remark text)";

    //建表语句  账户表
    public static final String CREATE_CLASS1 = "create table Class1("
            +"id integer primary key autoincrement, "
            +"name text)";

    //建表语句  账户表
    public static final String CREATE_CLASS2 = "create table Class2("
            +"id integer primary key autoincrement, "
            +"name text, "
            +"father text)";


    public OpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
                      int version) {
        super(context, name, factory, version);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub

        db.execSQL(CREATE_USER);   //创建用户表
        db.execSQL(CREATE_ITEM);   //创建账单表
        db.execSQL(CREATE_ACCOUNT);//创建账户表
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub

    }

}
